import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

/**
 * Generated class for the RefresherPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-refresher',
  templateUrl: 'refresher.html',
})
export class RefresherPage {

  public list=[];
  public j=0;

  constructor(public navCtrl: NavController, public navParams: NavParams) {

    for(var i=0;i<5;i++){
        this.list.push(`这是第${i}条数据 `);

    }
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad RefresherPage');
  }

  doRefresh(refresher){

      //模拟请求数据
      setTimeout(()=>{

        for(var i=0;i<5;i++){
            this.list.unshift(`这是第${this.j}条数据 `);
            this.j++;
    
        }

        refresher.complete();  /*加载完成以后重新渲染页面*/



      },1000)
  }

}
